<%@ page language="java" contentType="text/html; charset=utf-8"
		 pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://shiro.apache.org/tags" prefix="shiro"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>恒铸智能柜管理平台</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/layui/css/layui.css"media="all" />
	<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/public.css" media="all" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/date.format.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/resources/layui/layui.js"></script>
</head>
<body class="childrenBody">
<form class="layui-form">
	<style>
		.layui-form-item {
			display: inline-block;
		}
	</style>


	<div class="layui-form-item " id="useType">
		<label class="layui-form-label">名称:</label>
		<div class="layui-input-block">
			<input type="text" name="name" class="layui-input title" value="${caseType.getAttribute("name")}" >
		</div>
	</div>

	<input type="hidden" id="compId" value="${compId}">
    <input type="hidden" id="typeId" value="${typeId}">

	<div class="layui-form-item selectComp" id="selectComp">
		<label class="layui-form-label">公司:</label>
		<div class="layui-input-block">
			<select lay-filter="selectComp" name="compId" >
				<option value="-1">全部</option>
				<c:forEach items="${comps}" var="list" >
					<option value="${list.compId }">${list.compName }</option>
				</c:forEach>
			</select>
		</div>
	</div>

	<div class="layui-form-item select" id="isBindMobile" style="width: 200px;">
		<label class="layui-form-label">绑定手机:</label>
		<div class="layui-input-block">
			<select lay-filter="isBindMobile" name="isBindMobile">
				<option value="1">是</option>
				<option value="0">否</option>
			</select>
		</div>
	</div>


	<blockquote class="layui-elem-quote admin_search">
		<div>
			<a class="layui-btn addbtn" id="addbtn">添加</a>

		</div>
	</blockquote>
	<table id="FAQ" lay-filter="FAQ"></table>
	<!--操作-->
	<script type="text/html" id="publish">
		<a class="layui-btn layui-btn-xs" lay-event="edit"  id="edit" >编辑</a>
		<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del" value="{{ d.managerId }}">删除</a>
	</script>

		<button class="layui-btn" style="float: left;" type="submit">立即提交</button>

</form>
<script>
	layui.use(['form', 'layer', 'laydate', 'table', 'laytpl'], function () {
		var form = layui.form,
				layer = parent.layer === undefined ? layui.layer : top.layer,
				$ = layui.jquery,
				laydate = layui.laydate,
				laytpl = layui.laytpl,
				table = layui.table;
		$("#addbtn").on("click",function(){
			layui.layer.open({
				title: "添加",
				type: 2,
				area: ['380px', '280px'],
				content: '/caseType/addPrice?typeId=${typeId}',
			})
		})
		function edit(edit) {
			var editindex = layui.layer.open({
				title: "编辑",
				type: 2,
				area: ['380px', '280px'],
				content: '/caseType/addPrice?id='+ edit.id+"&typeId=${typeId}",
			});
		}

			var tableIns = table.render({
				elem: '#FAQ',
				url: '/caseType/list?typeId=${typeId}',
				cellMinWidth: 95,
				page: false,
				where:{sgin:1},
				height: "full-205",
				limit: 10,
				limits: [10, 15, 20, 25],
				id: "FAQ",
				cols: [[
					{field: 'theLenght', title: '时长（分钟）', align: 'center'},
					{field: 'thePrice', title: '价格（元）', align: 'center'},
					{title: '操作', width: 300, templet: '#publish', fixed: "right", align: "center"}
				]]
			});
		//列表操作
		table.on('tool(FAQ)', function (obj) {
			var layEvent = obj.event,
					data = obj.data;

			if (layEvent === 'del') {
				layer.confirm('确定删除此收费类型？', {icon: 3, title: '提示信息'}, function (index) {
					// console.log(index) sign:4
					if (index) {
						$.get("/caseType/del", {id:data.id,typeId: "${typeId}"}, function (res) {
							if (res.success) {
								layer.msg("删除成功");
								tableIns.reload();
							} else {
								layer.open({
									title: '温馨提示'
									, content: res.message
								});
								tableIns.reload();
							};
						});
					} else {
						tableIns.reload();
					};
				});

			}else if (layEvent === 'edit') {
				console.log(data)
				edit(data);
			}
		});

			$("form").submit(function(e){
				var param = $("form").serialize();
				console.log(param)

					$.post("/caseType/persistentSave",  {typeId: "${typeId}"},param, function (res) {
						if (res.success) {
							layer.msg(res.message)
							parent.window.location.reload();
						} else {
							layer.msg(res.message)
						}
					})

                // $.ajax({
                //     type: "POST",
                //     url: "/caseType/persistentsave",
                //     async: false,
                //     data: param,
                //     success: function (res) {
                //         if (res.success) {
				//
                //             alert("5555")
                //         } else {
				//
                //         }
                //     },
                //     error: function (err) {
				//
                //     }
                // })
			});



		//是否绑定手机
		// form.on("select(isBindMobile)", function (data) {
		// 	id = data.value;
		// 	// console.log(id)
		// 	//执行重载
		// 	table.reload('FAQ', {
		// 		url: '/main/getCaseList'
		// 		, page: {
		// 			curr: 1 //重新从第 1 页开始
		// 		}
		// 		, where: {
		// 			isBindMobile: id
		// 		}
		// 	});
		// })

	})
</script>
</body>
<script type="text/javascript">
	<shiro:hasPermission name="caseUseTime:setUseEndTime">
	sessionStorage.setItem("caseUseTime", "setUseEndTime");
	</shiro:hasPermission>
</script>


</html>